<?php

	$link = mysqli_connect('localhost', 'root', '') or die("Failed to connect to MySQL: " . mysql_error());
	if (mysqli_connect_errno()) {
	    echo 'Failed to connect to MySQL';
	    exit;
	}
	$sql = "USE web_db";
	$query = mysqli_query($link,$sql);

	$miss_nr = $_POST['miss_nr'];

	$sql = "DELETE FROM mech_mission WHERE mission_nr='$miss_nr'";
	$query = mysqli_query($link,$sql);

	if($query){
		echo "Borrado de mech_mission<br>";
	}

	$sql = "DELETE FROM country_mission WHERE mission_nr='$miss_nr'";
	$query = mysqli_query($link,$sql);

	if($query){
		echo "Borrado de mech_mission<br>";
	}

	$sql = "DELETE FROM mission WHERE miss_nr='$miss_nr'";
	$query = mysqli_query($link,$sql);

	if($query){
		echo "Borrado de mission<br>";
	}

	header("location:missions.php");
?>